home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Add-Ons / MPW / MPW fixit / fixit.l < prev    next >
Encoding:
Lex Description  |  1996-07-08  |  1.2 KB  |  54 lines  |  [TEXT/MPS ]

  1. %{
  2.  
  3. /* File fixit.l Copyright (C) 1996 by John R. Montbriand.  All Rights Reserved. */
  4.  
  5. /* File fixit.l
  6.  
  7.     Copyright (C) 1996 by John Montbriand.  All Rights Reserved.
  8.     
  9.     Distribute freely in areas where the laws of copyright apply.
  10.     
  11.     Use at your own risk.
  12.     
  13.     Do not distribute modified copies.
  14.     
  15.     These various fixmath routines and libraries are for free!
  16.     
  17.     See the file fixit.txt for details.
  18.     
  19. */
  20.  
  21. #include "y.tab.h"
  22. #include "StdLib.h"
  23. #include "FixMath.h"
  24. #include "ToolUtils.h"
  25.  
  26. int yywrap(void);
  27. extern int yylval;
  28.  
  29. %}
  30.  
  31. %%
  32.  
  33. sqrt                yylval = (long) yytext; return SQUARE_ROOT;
  34. sqr                    yylval = (long) yytext; return SQUARE;
  35. cos                    yylval = (long) yytext; return COSINE;
  36. sin                    yylval = (long) yytext; return SINE;
  37. tan                    yylval = (long) yytext; return TANGENT;
  38. \*\*                yylval = (long) yytext; return EXPONENT;
  39. [a-z_][0-9_a-z]*    yylval = (long) yytext; return IDENTIFIER;
  40. [0-9]+                yylval = (long) FixRatio(atoi(yytext), 1); return NUMBER;
  41. [0-9]+\.[0-9]+        yylval = (long) X2Fix(atof(yytext)); return NUMBER;
  42. [()+*/\-]            yylval = (long) *yytext; return *yytext;
  43. [ \t]+|#.*            /* eat up whitespace */
  44. .                   printf( "Unrecognized character: '%s'\n", yytext );
  45.  
  46.  
  47. %%
  48.  
  49. int yywrap(void) {
  50.     return 1;
  51. }
  52.  
  53. /* end of file fixit.l */
  54.